<?php

/**
 * @file
 * Customize the display of a complete webform.
 *
 * This file may be renamed "webform-form-[nid].tpl.php" to target a specific
 * webform on your site. Or you can leave it "webform-form.tpl.php" to affect
 * all webforms on your site.
 *
 * Available variables:
 * - $form: The complete form array.
 * - $nid: The node ID of the Webform.
 *
 * The $form array contains two main pieces:
 * - $form['submitted']: The main content of the user-created form.
 * - $form['details']: Internal information stored by Webform.
 */
?>
<?php
  global $base_url;
  drupal_add_js('var js_base_url = "' . $base_url . '/";', 'inline');
  drupal_add_js(drupal_get_path('module', 'webformview') . '/js/jquery.validate.js');
  drupal_add_js(drupal_get_path('module', 'webformview') . '/js/webform_common.js');
  drupal_add_js(drupal_get_path('module', 'webformview') . '/js/webform_excel.js');
 
  $PG_initiation_nid = PG_INITIATION_FORM_NID;
  if ( isset($form['#node']->nid) && $form['#node']->nid == $PG_initiation_nid) {
    drupal_add_js(drupal_get_path('module', 'webformview') . '/js/webform_validate.js');
  }// End if for 'P&G Initiation' de
  else if ( isset($form['#node']->nid) && $form['#node']->nid == PG_IF_JAP) {
    drupal_add_js(drupal_get_path('module', 'webformview') . '/js/webform_validate_jp.js');
  } else if ( isset($form['#node']->nid) && $form['#node']->nid == PG_IF_TUR) {
    drupal_add_js(drupal_get_path('module', 'webformview') . '/js/webform_validate_tur.js');
  } else if ( isset($form['#node']->nid) && $form['#node']->nid == PG_IF_MEX) {
    drupal_add_js(drupal_get_path('module', 'webformview') . '/js/webform_validate_mex.js');
  } else if ( isset($form['#node']->nid) && $form['#node']->nid == PG_IF_AU) {
    drupal_add_js(drupal_get_path('module', 'webformview') . '/js/webform_validate_au.js');
  }
  
  // Print out the main part of the form.
  // Feel free to break this up and move the pieces within the array.
  print drupal_render($form['submitted']);

  // Always print out the entire $form. This renders the remaining pieces of the
  // form that haven't yet been rendered above.
  print drupal_render_children($form);
